<?php
// $Id$

/**
 * Controller_Admin_Web 控制器
 */
class Controller_Admin_educlass extends Controller_Abstract {

	/**
	 * 视频分类
	 */
	function actionIndex()
	{
		$this->union_table = educlass::meta();
		$catelist=educategory::find()->asArray()->getAll();
		$catedata=Helper_Array::toHashmap($catelist, 'id','name');
		$this->_view['catedata'] = $catedata;
		$this->lists();
	}

	/**
	 * 视频分类设置
	 */

	function actionAdd() {
		//设置要操作的表单，并设置自动插入方式
		$this->union_table = educlass::meta ();
		$handle = new helper_autoinsert ( $this->union_table );
		$form = new Form_educlass_add ( url ( $this->_context->controller_name . '/' . $this->_context->action_name ) );
		//这里面会自动将get方式获取的参数传递到表单里面去的
		$result = $handle->add ( $form, 'id', $_GET );
		if ($this->_context->isGET ()) {
			//传递$form值
			$this->_view ['form'] = $result;
			$this->_viewname = '../form/add';
			$catelist=educategory::find()->asArray()->getAll();
			$catedata=Helper_Array::toHashmap($catelist, 'id','name');
			$form->element('cate_id')->items= $catedata;
			$form->element('acct_id')->value= $_SESSION['acct']['id'];
		} else {
			//记录日志
			if(!$_POST['id'])	{
				Syslog::logs ( '添加课程,id :' . $handle->form_database_obj->id );
			}else{
				Syslog::logs ( '添加课程,id :' . $handle->form_database_obj->id );
			}
			if($handle->status=='success')
				$this->_context->forwardUrl = url("educlass/index");
			return call_user_func_array(array($this,$handle->status),array($result));
		}
	}

	/**
	 * 删除视频分类
	 */
	function actionDel() {
		Syslog::logs("删除课程，ID：".print_r($this->_context->ids,true));
		$this->union_table = educlass::meta();
		$this->delete(array('id'=>$this->_context->ids));
	}



}


